package cn.tworice.common.vo;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 控制层返回结果
 * @author 二饭[tworice@sina.cn][2022/1/15 11:09]
 */

public class RequestResult implements Serializable {
    private static final long serialVersionUID = 7270509107164711433L;

    private StatusCode status;

    private Map<String, Object> data;

    public RequestResult() {
        super();
        this.status = new StatusCode(0,"请求成功");
        data = new HashMap<>();
    }

    public RequestResult(StatusCode statusCode) {
        super();
        this.status = statusCode;
    }

    public StatusCode getStatus() {
        return status;
    }

    public void setStatus(StatusCode status) {
        this.status = status;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public void appendData(String key, Object value){
        this.data.put(key, value);
    }

    public void removeData(String key){
        this.data.remove(key);
    }

    public void clearData(){
        this.data.clear();
    }
}
